package com.codoon.unova.ui;

import java.util.Date;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import com.codoon.unova.logic.ActivityManager;
import com.codoon.unova.util.ConfigManager;
import com.codoon.unova.util.DateUtil;
import com.uwatch.helowin.R;


public class SportsOneActivity extends HorizontalBaseActivity {
	private ImageView iv_back;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_yesterday);
		super.onCreate(savedInstanceState);
		ActivityManager.getInstance().pushActivity(this);
		Bundle bundle = getIntent().getBundleExtra("bundle");
		if (bundle == null) {
			currrentIndex = ConfigManager.getIntValue(getApplicationContext(), ConfigManager.CURRENT_INDEX);
			str_date = DateUtil.DateToString(new Date());
		} else {
			currrentIndex = bundle.getInt("currentIndex");
			str_date = bundle.getString("date");
		}
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		String curr_date = DateUtil.DateToString(new Date());
		if (currentSelectedDate.equals(DateUtil.addDate(curr_date, -1))) {
			tv_date.setText(getString(R.string.yesterday));
		}
	}

	@Override
	protected void initView() {
		// TODO Auto-generated method stub
		super.initView();
		iv_back = (ImageView) findViewById(R.id.iv_back);
		iv_back.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		super.onClick(v);
		switch (v.getId()) {
		case R.id.iv_back:
			bundle = new Bundle();
			bundle.putInt("currentIndex", 0);
			changeView(SportsMainActivity.class, bundle, true);
			overridePendingTransition(R.anim.left_in, R.anim.left_out);
			ActivityManager.getInstance().popAllActivityExceptOne();
			break;
		default:
			break;
		}
	}

	@Override
	protected void showLeft() {
		// TODO Auto-generated method stub
		super.showLeft();
		ActivityManager.getInstance().popActivity(this);
	}

	@Override
	protected void showRight() {
		// TODO Auto-generated method stub
		super.showRight();
		ActivityManager.getInstance().popActivity(this);
	}

}
